#ifndef MEMORYGAME_H
#define MEMORYGAME_H

#include <QtGui/QMainWindow>
#include "ui_memorygame.h"
#include "qgraphicsview.h"
#include "tableschema.h"

class PlayerWidget;
class QGraphicsItemQuestionFullScreen;
class MemoryGame : public QMainWindow
{
    Q_OBJECT

public:
    MemoryGame( const QVector<Topic> & topicVector, const QVector<int> & questionValues, int playersCount, QWidget * parent = 0, Qt::WFlags flags = 0 );
    ~MemoryGame();
    void openQuestion( Question & question );

protected:
    virtual void resizeEvent( QResizeEvent * event );

private slots:
    void onTimer();

private:
    void addPlayers( int playersCount );
    void addItems( const QVector<int> & questionValues );
    virtual void keyPressEvent( QKeyEvent * event );
    void pressedPlayerKey( int playerIndex );
    void executeAnswer( bool rightAnswer );
    void setQuestionStatus( QuestionStatus::Enum questionStatus );
    QVector<int> playerScoreVector() const;
    void setPlayersScore( const QVector<int> & playerScoreVector );

private:
    Ui::memorygameClass ui;
    QVector<Topic> m_topicVector;
    QGraphicsView * m_graphicsView;
    QGraphicsScene * m_graphicsScene;
    QGraphicsItemQuestionFullScreen * m_fullScreenQuestion;
    QProgressBar * m_progressBar;
    QVector< PlayerWidget * > m_playerWidgetVector;
    QSet< int > m_blockedPlayerIndexes;
    QTimer m_timer;
    int m_pressedKey;
    int m_timerValue;
    Question m_currentQuestion;
};

#endif
